/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package elaborate.task.impl;

import elaborate.task.DefaultTaskQueueFactory;
import elaborate.task.Task;
import elaborate.task.TaskQueue;
import elaborate.task.TaskQueueEvent;
import elaborate.task.TaskQueueEventListener;

/**
 *
 * @author lendle
 */
public class Test implements TaskQueueEventListener{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception{
        // TODO code application logic here
        Test test=new Test();
        TaskQueue queue=new DefaultTaskQueueFactory().newTaskQueue();
        queue.addTaskQueueListener(test);
        queue.start();
        for(int i=0; i<100; i++){
            queue.addTask(new Task(){

                @Override
                public Object run() throws Exception {
                    Thread.sleep(100);
                    return null;
                }
            });
        }
        Thread.sleep(60000);
    }

    @Override
    public void taskCompleted(TaskQueueEvent e) {
        System.out.println("taskCompleted: "+e);
    }

    @Override
    public void taskAdded(TaskQueueEvent e) {
        System.out.println("taskAdded: "+e);
    }

    @Override
    public void taskFailed(TaskQueueEvent e) {
        System.out.println("taskFailed: "+e);
    }

    @Override
    public void taskQueueEmptied(TaskQueueEvent e) {
        System.out.println("queueEmptied: "+e);
    }

    @Override
    public void taskQueueStarted(TaskQueueEvent e) {
        System.out.println("queueStarted: "+e);
    }

    @Override
    public void taskQueueStopped(TaskQueueEvent e) {
        System.out.println("queueStopped: "+e);
    }

    @Override
    public void taskQueuePaused(TaskQueueEvent e) {
        System.out.println("queuePaused: "+e);
    }

    @Override
    public void taskQueueResumed(TaskQueueEvent e) {
        System.out.println("queueResumed: "+e);
    }
}
